package com.laicunba.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.laicunba.pojo.FinancingTargetTagDO;
import com.laicunba.service.FinancingTargetTagService;

@Service
public class FinancingTargetTagServiceImpl extends BaseServiceImpl implements FinancingTargetTagService {

	@Override
	public List<FinancingTargetTagDO> find(String financingTargetId) {
		return queryDao.selectList("FINANCING_TARGET_TAG.find", financingTargetId);
	}

	@Override
	public boolean enable(String financingTargetId, String tag) {
		FinancingTargetTagDO tagDO = new FinancingTargetTagDO();
		tagDO.setFinancingTargetId(financingTargetId);
		tagDO.setTag(tag);
		return create(tagDO);
	}

	@Override
	public boolean disable(String financingTargetId, String tag) {
		Map map = new HashMap();
		map.put("financingTargetId", financingTargetId);
		map.put("tag", tag);
		return updateDao.update("FINANCING_TARGET_TAG.delete", map) > 0;
	}

	@Override
	public List<FinancingTargetTagDO> findOnsale() {
		return queryDao.selectList("FINANCING_TARGET_TAG.findOnsale", null);
	}
	
	@Override
	public List<FinancingTargetTagDO> findListByTag(String tag) {
		return queryDao.selectList("FINANCING_TARGET_TAG.findListByTag", tag);
	}
	
	@Override
	public FinancingTargetTagDO findTargetTag(String financingTargetId, String tag) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("financingTargetId", financingTargetId);
		param.put("tag", tag);
		return queryDao.selectOne("FINANCING_TARGET_TAG.findTargetTag", param);
	}
}
